<template>
  <div class="pk-btn">
    <div class="pk-btn-item" 
      @click="handerClick" 
      :class="[
        'pk-btn-'+type,
        'pk-btn-'+size, 
        {'pk-btn-blank': isBlank}, 
        {'is-round': round},
        {'is-plain': plain}
      ]">
      <slot></slot>
    </div> 
    <div class="pk-btn-opentype" v-if="$slots['openType'] && openType">
      <slot name="openType"></slot>
    </div>
  </div>
</template>

<script setup>
import { defineProps, defineEmits } from 'vue';
const emits = defineEmits(['click'])
const props = defineProps({
  type: {
    type: String,
    default: "default"
  },
  isBlank:{
    type: Boolean,
    default: false
  },
  round:{
    type: Boolean,
    default: false
  }, 
  size:{
    type:String,
    default: ''
  },
  plain:{
    type: Boolean,
    default: false
  },
  disabled: {
    type: Boolean,
    default: false
  },
  openType: {
    type: Boolean,
    default: true
  }
})

const handerClick = (e) => {
  if (props.disabled) {
    return
  }
  emits('click', e)
}

</script>

<style lang="scss" scoped>
.pk-btn{
  position: relative;
  &-item{
    display: inline-block;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    background: #fff;
    border: 1px solid #dcdfe6;
    color: #606266;
    -webkit-appearance: none;
    text-align: center;
    box-sizing: border-box;
    outline: none;
    margin: 0;
    transition: .1s;
    font-weight: 500;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    padding: 12px 20px;
    font-size: 14px;
    border-radius: 4px;
  }
  &-primary{
    color: #fff;
    background-color: #409eff;
    border-color: #409eff; 
  }
  &-success{
    color: #fff;
    background-color: #00b4b3;
    border-color: #00b4b3;
    .is-plain{
      background: #fff;
      border-color: #00b4b3;
      color: #00b4b3;
    }
  }
  &-info{
    color: #fff;
    background-color: #909399;
    border-color: #909399;
  }
  &-warning{
    color: #fff;
    background-color: #e6a23c;
    border-color: #e6a23c;
  }
  &-danger{
    color: #fff;
    background-color: #f56c6c;
    border-color: #f56c6c;
    .is-plain{
     
    }
  }
  &-blank{
    width: 100%;
  }

  .is-round{
    border-radius: 40px;
  }

  &-default {
    .is-round{
      padding: 12px 23px;
    } 
  } 

  &-large{
    padding: 16px 24px;
    font-size: 14px;
    border-radius: 4px;
    .is-round{
      padding: 12px 24px;
    }
  }

  &-medium{
    padding: 10px 20px;
    font-size: 14px;
    border-radius: 4px;
    .is-round{
      padding: 10px 20px;
    }
  }

  &-small{
    padding: 9px 15px;
    font-size: 12px;
    border-radius: 3px;
    .is-round{
      padding: 9px 15px;
    }
  }

  &-mini{
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 3px;
    .is-round{
      padding: 7px 15px;
    }
  }
  &-opentype{
    opacity: 0;
    position: absolute;
    top:0;
    left:0;
    right:0;
    bottom:0
  }
}

.pk-btn-danger.is-plain{
  background: #fff!important;
  border-color: #f56c6c!important;
  color: #f56c6c!important;
}

.pk-btn-warning.is-plain{
  background: #fff;
  border-color: #e6a23c;
  color: #e6a23c;
}
.pk-btn-info.is-plain{
  background: #fff;
  border-color: #909399;
  color: #909399;
}
.pk-btn-success.is-plain{
  background: #fff;
  border-color: #67c23a;
  color: #67c23a;
}

.pk-btn-primary.is-plain{
  background: #fff;
  border-color: #409eff;
  color: #409eff;
}



</style>